package main

import (
	"fmt"
)

func escForeColor(color string) string {
	if color == "black" {
		return ";30"
	} else if color == "red" {
		return ";31"
	} else if color == "green" {
		return ";32"
	} else if color == "yellow" {
		return ";33"
	} else if color == "blue" {
		return ";34"
	} else if color == "magenta" {
		return ";35"
	} else if color == "cyan" {
		return ";36"
	} else if color == "white" {
		return ";37"
	} else {
		panic("Illegal color: " + color)
	}
}

func style(fg, format string, args ...interface{}) string {
	return "\033[0" + escForeColor(fg) + "m" + fmt.Sprintf(format, args...) + "\033[0m"
}
